﻿'use strict';

// This code runs when the DOM is ready and creates a context object which is needed to use the SharePoint object model
$(document).ready(function () {
    //$.jSPCSOM.getListData({ listName: "TestList" }).done(function (result) {
    //    //alert("Result was: " + result.dataLoadSuccess + " Message: " + result.message);
    //    $("#message").html("<b>Was data loaded:</b>" + result.dataLoadSuccess + "<br/><b>Message:</b> " + result.message);
    //});

    var context = SP.ClientContext.get_current();
    var web = context.get_web();
    context.load(web);

    var list = context.get_web().get_lists().getByTitle('TestList');
    context.load(list);

    $.jSPCSOM.execute({ clientContext: context, data: { web: web, list: list } }).then(function (result) {
        if (result.loadedSuccess)
            $("#message").html("<b>Web Title: </b>" + result.data.web.get_title() + " <br/><b>List Title: </b>" + result.data.list.get_title());
            //alert(result.data.web.get_title() + " " + result.data.list.get_title());
    });
});

